#include "tracimportprojectselectionpage.h"
#include "tracimportprojectselectwidget.h"
#include "tracvalidationpage.h"
#include "tracsettings.h"

#include <QtGui/QVBoxLayout>
#include <QtGui/QTextEdit>
#include <QDebug>

namespace Trac {
namespace Internal {

TracImportProjectSelectionPage::TracImportProjectSelectionPage(TracValidationPage *validationPage,
                                                               QWidget *parent) :
    QWizardPage(parent),
    m_validationPage(validationPage),
    m_widget(new TracImportProjectSelectWidget())
{
    connect(m_widget, SIGNAL(validChanged(bool)), this, SIGNAL(completeChanged()));
    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(m_widget);
    setLayout(layout);
    setTitle(tr("Select project"));
    setSubTitle(tr("Select a project to import from the remote host"));

}

TracImportProjectSelectionPage::~TracImportProjectSelectionPage()
{

}

void TracImportProjectSelectionPage::initializePage()
{

    if(m_widget->connectionUrl() != TracSettings::instance()->hostName()) {
        m_widget->initialize();
        m_widget->requestProjectCategories();
    }
}

bool TracImportProjectSelectionPage::isComplete() const
{
    return m_widget->isValid();

}



} // namespace Internal
} // namespace Trac
